import router from "../project-base/router";
import allRoute from '../project-base/allRoutes'

function boot () {

  if (!localStorage.getItem('routes')) return

  const r = JSON.parse(localStorage.getItem('routes') as string)
  const c:any = []

  r.forEach((i:any) => {
    const temp = allRoute.find((j:any) => {
      return j.path === i.path
    })
    if (temp) {
      c.push(temp)
    }
  })

  const tr =  {
    path: '/Home',
    name: 'Home',
    component: () => import('@/views/Home.vue'),
    redirect: c[0].path,
    children: c
  }

  router.addRoute(tr)
}

export default boot